//
//  ReportProjectListCell.m
//  efairy
//
//  Created by 李锋 on 2019/3/12.
//  Copyright © 2019年 East. All rights reserved.
//

#import "ReportProjectListCell.h"

@implementation ReportProjectListCell

- (void)awakeFromNib {
    [super awakeFromNib];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if(self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]){
        [self initView];
    }
    return self;
}

-(void)initView{
    _checkImageView = [[UIImageView alloc]init];
    _chooseImage = [UIImage imageNamed:@"icon_checked"];//选中后的图标
    _unChooseImage = [UIImage imageNamed:@"icon_no_checked"];//未选中的图标
    _checkImageView.image = _unChooseImage;
    
    _rightView = [[UIView alloc]init];
    _rightView.layer.cornerRadius = 6;
    _rightView.backgroundColor = [UIColor whiteColor];
    
    _projectName = [[UILabel alloc]init];//项目名字
    _projectName.textColor = ColorFromRGB(0x333333);
    _projectName.font = [UIFont boldSystemFontOfSize:14.f];
    
    
    _totalUser = [[UILabel alloc]init];//用户数
    _totalUser.textColor = ColorFromRGB(0x666666);
    _totalUser.font = [UIFont systemFontOfSize:16.f];
    _totalUser.textAlignment = NSTextAlignmentRight;
    
    _userImageView =[[UIImageView alloc]init];
    _userImage = [UIImage imageNamed:@"icon_people_num"];//人数图标
    _userImageView.image = _userImage;
    
    
   _devicesTitle = [[UILabel alloc]init];//设备数title
    _devicesTitle.textColor = ColorFromRGB(0x484848);
    _devicesTitle.font = [UIFont systemFontOfSize:13.f];
    _devicesTitle.text = @"设备数";
    
   _devicesNumber = [[UILabel alloc]init];//设备数
    _devicesNumber.textColor = ColorFromRGB(0x484848);
    _devicesNumber.font = [UIFont systemFontOfSize:13.f];
    
    
    [self.contentView sd_addSubviews:@[_checkImageView,_rightView]];
    _checkImageView.sd_layout.widthIs(20).heightIs(20).leftSpaceToView(self.contentView, 9)
    .topSpaceToView(self.contentView, 25.5);
    _rightView.sd_layout.heightIs(72).widthIs(SCREEN_WIDTH-46).leftSpaceToView(_checkImageView, 9)
    .topSpaceToView(self.contentView, 0);
    
    [_rightView sd_addSubviews:@[_projectName,_totalUser,_userImageView,_devicesTitle,_devicesNumber]];
    _projectName.sd_layout.heightIs(14).leftSpaceToView(_rightView, 16).rightSpaceToView(_rightView, 60)
    .topSpaceToView(_rightView, 16).autoHeightRatio(0);
    _totalUser.sd_layout.heightIs(14).widthIs(28).rightSpaceToView(_rightView, 34).topSpaceToView(_rightView, 16);
    _userImageView.sd_layout.heightIs(12).widthIs(12).rightSpaceToView(_rightView, 16).topSpaceToView(_rightView, 17);
    _devicesTitle.sd_layout.heightIs(13).widthIs(45).leftSpaceToView(_rightView, 16).topSpaceToView(_projectName, 12);
    _devicesNumber.sd_layout.heightIs(13).widthIs(200).leftSpaceToView(_devicesTitle, 3).topSpaceToView(_projectName, 12);
    
    self.contentView.backgroundColor = ColorFromRGB(0xeff0f4);
    [self setupAutoHeightWithBottomView:_rightView bottomMargin:0];
  
}

-(void)setDataModel:(ReportProjectListModel *)data{
    if(data){
        if(data.isChecked){
            _checkImageView.image = _chooseImage;
        }else{
            _checkImageView.image = _unChooseImage;
        }
        _projectName.text = data.efairyproject_name;
        _totalUser.text = data.efairyproject_total_users;
        _devicesNumber.text = data.efairyproject_total_devices;
    }
}

@end
